package com.xmkj.winmoney.mine.adapter;

import android.content.Context;
import android.widget.RelativeLayout;

import com.common.retrofit.entity.bean.YouHuiJuanBean;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.winmoney.R;

import java.util.List;

/**
 * Created by chen on 2018/4/1.
 */

public class MyCardsAdapter extends CommonAdapter<YouHuiJuanBean.ListsBean> {
    public MyCardsAdapter(Context context, List<YouHuiJuanBean.ListsBean> data) {
        super(context, data);
    }

    @Override
    protected void convert(ViewHolder holder, YouHuiJuanBean.ListsBean item, int position) {
        holder.setText(R.id.tv_info,item.siteinfo);
        holder.setText(R.id.tv_time,item.end_time);
        holder.setText(R.id.tv_zhekou,"-"+item.rate+"%");
        RelativeLayout rl = holder.getView(R.id.rl_juan);
        if("1".equals(item.status)){
            holder.setText(R.id.tv_state,"未使用");
            rl.setBackground(mContext.getResources().getDrawable(R.mipmap.card_no_use));
        }else   if("2".equals(item.status)){
            holder.setText(R.id.tv_state,"已使用");
            rl.setBackground(mContext.getResources().getDrawable(R.mipmap.card_canot_use));
        }else   if("3".equals(item.status)){
            rl.setBackground(mContext.getResources().getDrawable(R.mipmap.card_canot_use));
            holder.setText(R.id.tv_state,"已过期");
        }
        holder.setOnClickListener(R.id.rl_juan, new OnItemChildClickListener());


    }

    @Override
    protected int getItemViewLayoutId(int position, YouHuiJuanBean.ListsBean item) {
        return R.layout.item_my_cards;
    }
}
